package com.cf.api.model;

public class ApiResp {

    private int code; // 错误代码
    private String msg; // 错误提示信息
    private String description; // 错误描述信息（程序调试用）

    private Object data; // 用于封装返回的数据
    
    private final static int SUCCESS_CODE = 0;
    private final static int BUSINESS_CODE = 300;

    public static  ApiResp success() {
        return new ApiResp(SUCCESS_CODE);
    }

    public static  ApiResp success(String msg) {
        return new ApiResp(SUCCESS_CODE, msg);
    }

    public static  ApiResp success(Object data) {
        return new ApiResp(SUCCESS_CODE, data);
    }

    public static  ApiResp success(String msg, Object data) {
        return new ApiResp(SUCCESS_CODE, msg, data);
    }

    public static  ApiResp error(String msg) {
        return new ApiResp(BUSINESS_CODE, msg);
    }

    public static  ApiResp error(String msg, String description) {
        return new ApiResp(BUSINESS_CODE, msg, description);
    }
    
    public static  ApiResp build(int code, String msg) {
        return new ApiResp(code, msg);
    }

    public static  ApiResp build(int code, Object data) {
        return new ApiResp(code, data);
    }

    public static  ApiResp build(int code, String msg, Object data) {
        return new ApiResp(code, msg, data);
    }

    public static  ApiResp build(int code, String msg, String description) {
        return new ApiResp(code, msg, description);
    }

    public static  ApiResp build(int code, String msg, String description, Object data) {
        return new ApiResp(code, msg, description, data);
    }

    public ApiResp(int code) {
        super();
        this.code = code;
    }

    public ApiResp(int code, String msg) {
        super();
        this.code = code;
        this.msg = msg;
    }

    public ApiResp(int code, Object data) {
        super();
        this.code = code;
        this.data = data;
    }

    public ApiResp(int code, String msg, Object data) {
        this(code, msg);
        this.data = data;
    }

    public ApiResp(int code, String msg, String description) {
        this(code, msg);
        this.description = description;
    }

    public ApiResp(int code, String msg, String description, Object data) {
        this(code, msg);
        this.description = description;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return msg;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
